// $ANTLR 2.7.6 (2005-12-22): "DatabaseViewFormula.g" -> "DatabaseViewFormulaParser.java"$

package lumis.portal.group.databaseviewmembership.formula;
// @version $Revision: 10458 $ $Date: 2009-06-02 15:49:09 -0300 (Tue, 02 Jun 2009) $
// @since 4.2.1

import antlr.TokenBuffer;
import antlr.TokenStreamException;
import antlr.TokenStreamIOException;
import antlr.ANTLRException;
import antlr.LLkParser;
import antlr.Token;
import antlr.TokenStream;
import antlr.RecognitionException;
import antlr.NoViableAltException;
import antlr.MismatchedTokenException;
import antlr.SemanticException;
import antlr.ParserSharedInputState;
import antlr.collections.impl.BitSet;
import antlr.collections.AST;
import java.util.Hashtable;
import antlr.ASTFactory;
import antlr.ASTPair;
import antlr.collections.impl.ASTArray;

class DatabaseViewFormulaParser extends antlr.LLkParser       implements DatabaseViewFormulaParserTokenTypes
 {

protected DatabaseViewFormulaParser(TokenBuffer tokenBuf, int k) {
  super(tokenBuf,k);
  tokenNames = _tokenNames;
  buildTokenTypeASTClassMap();
  astFactory = new ASTFactory(getTokenTypeToASTClassMap());
}

public DatabaseViewFormulaParser(TokenBuffer tokenBuf) {
  this(tokenBuf,1);
}

protected DatabaseViewFormulaParser(TokenStream lexer, int k) {
  super(lexer,k);
  tokenNames = _tokenNames;
  buildTokenTypeASTClassMap();
  astFactory = new ASTFactory(getTokenTypeToASTClassMap());
}

public DatabaseViewFormulaParser(TokenStream lexer) {
  this(lexer,1);
}

public DatabaseViewFormulaParser(ParserSharedInputState state) {
  super(state,1);
  tokenNames = _tokenNames;
  buildTokenTypeASTClassMap();
  astFactory = new ASTFactory(getTokenTypeToASTClassMap());
}

	public final void expr() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST expr_AST = null;
		
		statement();
		astFactory.addASTChild(currentAST, returnAST);
		match(Token.EOF_TYPE);
		expr_AST = (AST)currentAST.root;
		returnAST = expr_AST;
	}
	
	public final void statement() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST statement_AST = null;
		
		{
		switch ( LA(1)) {
		case LPAR:
		{
			pst();
			astFactory.addASTChild(currentAST, returnAST);
			break;
		}
		case COMPARISON_ID:
		{
			sst();
			astFactory.addASTChild(currentAST, returnAST);
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
		statement_AST = (AST)currentAST.root;
		returnAST = statement_AST;
	}
	
	public final void pst() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST pst_AST = null;
		
		match(LPAR);
		statement();
		astFactory.addASTChild(currentAST, returnAST);
		match(RPAR);
		{
		switch ( LA(1)) {
		case CONCATENATION:
		{
			AST tmp4_AST = null;
			tmp4_AST = astFactory.create(LT(1));
			astFactory.makeASTRoot(currentAST, tmp4_AST);
			match(CONCATENATION);
			statement();
			astFactory.addASTChild(currentAST, returnAST);
			break;
		}
		case EOF:
		case RPAR:
		{
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
		pst_AST = (AST)currentAST.root;
		returnAST = pst_AST;
	}
	
	public final void sst() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST sst_AST = null;
		
		comparison_statement();
		astFactory.addASTChild(currentAST, returnAST);
		{
		switch ( LA(1)) {
		case CONCATENATION:
		{
			AST tmp5_AST = null;
			tmp5_AST = astFactory.create(LT(1));
			astFactory.makeASTRoot(currentAST, tmp5_AST);
			match(CONCATENATION);
			statement();
			astFactory.addASTChild(currentAST, returnAST);
			break;
		}
		case EOF:
		case RPAR:
		{
			break;
		}
		default:
		{
			throw new NoViableAltException(LT(1), getFilename());
		}
		}
		}
		sst_AST = (AST)currentAST.root;
		returnAST = sst_AST;
	}
	
	public final void comparison_statement() throws RecognitionException, TokenStreamException {
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST comparison_statement_AST = null;
		
		AST tmp6_AST = null;
		tmp6_AST = astFactory.create(LT(1));
		astFactory.addASTChild(currentAST, tmp6_AST);
		match(COMPARISON_ID);
		comparison_statement_AST = (AST)currentAST.root;
		returnAST = comparison_statement_AST;
	}
	
	
	public static final String[] _tokenNames = {
		"<0>",
		"EOF",
		"<2>",
		"NULL_TREE_LOOKAHEAD",
		"left parentheses",
		"right parentheses",
		"CONCATENATION",
		"COMPARISON_ID",
		"WS"
	};
	
	protected void buildTokenTypeASTClassMap() {
		tokenTypeToASTClassMap=null;
	};
	
	
	}
